<?//添加分销商
use pft\Member\MemberAccount;

include('common/header.html');
include("common/left.html");
include('common/autoload.php');
//if($_SESSION['dtype']) {
//    exit('不合法的身份！');
//}
if(isset($_SESSION['qx']) && $_SESSION['dtype']){
	if(!strpos('Placeholder'.$_SESSION['qx'],'addlow')){
		exit('不合法的身份！');
	}
}

$mem = new MemberAccount($GLOBALS['le']);
//判断该供应商是否已添加admin为他的分销商
$ret = $mem->chkRelationship($_SESSION['memberID'], MemberAccount::ADMINID);

$csrf_token = genCsrfToken();
$data = array('csrf_token'=>$csrf_token,'web_title'=>$GLOBALS['web_title']);
if(!$ret['id']) {
    $data['admin'] = $mem->GetOne(MemberAccount::ADMINID);
//    print_r($data['admin']);
}

$GLOBALS['le']->query("SELECT add_saler_type FROM pft_member_extinfo WHERE fid={$_SESSION['memberID']}");
$GLOBALS['le']->fetch_assoc();
$ast = $GLOBALS['le']->f('add_saler_type');
//判断该供应商添加分销商的类型，只有管理员可以设置此项。合作比较深入的供应商可以使用搜索的方式添加分销商。否则都只能添加下级的分销商。


if($ast == 1){ 
	$tplFile = 'tpl/distributor_add.tpl';
	}
else{
    $tplFile = 'tpl/distributor_only_add_test.tpl';
	}

if($_GET['cs']){
    echo "<pre>";
    print_r($data);
    echo "</pre>";
}
$tplEngine = new IdiotTplEngine($tplFile);
$tplEngine->SetData($data);
echo $tplEngine->Render();
?>

        <link rel="stylesheet" type="text/css" href="http://www.12301.cc/css/common/reset_style.css"/>
        <link rel="stylesheet" href="http://www.12301.cc/css/new/distributor_add.css"/>

<?include('common/footer.html');?>